package com.ruoyi.zhjd.laboratory.modules.groutingRecord.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhjd.laboratory.modules.groutingRecord.entity.GroutingRecord;
import com.ruoyi.zhjd.laboratory.modules.groutingRecord.service.LGroutingRecordService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 压浆记录(GroutingRecord)表控制层
 *
 * @author makejava
 * @since 2023-07-12 14:58:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/laboratory/groutingRecord")
public class LGroutingRecordController {

    private LGroutingRecordService LGroutingRecordService;

    /**
     * 分页
     *
     * @param params 查询条件
     * @return Result 分页列表
     */
    @GetMapping("page")
    public R<IPage<GroutingRecord>> page(@RequestParam Map<String, Object> params) {
        IPage<GroutingRecord> page = LGroutingRecordService.page(params);
        return R.ok(page);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/find/{id}")
    public R selectOne(@PathVariable("id") String id) {
        return R.ok(LGroutingRecordService.getInfoById(id));
    }

    /**
     * 新增数据
     *
     * @param groutingRecord 实体对象
     * @return 新增结果
     */
    @PostMapping("/insert")
    public R insert(@RequestBody GroutingRecord groutingRecord) {
        LGroutingRecordService.insertGroutingRecord(groutingRecord);
        return R.ok();
    }

    /**
     * 修改数据
     *
     * @param groutingRecord 实体对象
     * @return 修改结果
     */
    @PutMapping("updateGroutingRecord")
    public R update(@RequestBody GroutingRecord groutingRecord) {
        LGroutingRecordService.updateGroutingRecord(groutingRecord);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping("deleteByIds")
    public R delete(@RequestBody String[] ids) {
        LGroutingRecordService.deleteByIds(Arrays.asList(ids));
        return R.ok();
    }
}

